<?php
/**
 * Created by PhpStorm.
 * User: DongYao
 * Date: 2018/1/5
 * Time: 下午3:13
 */

namespace App\Support\OperationLog;


use App\Tables\OperationLog;
use Carbon\Carbon;

class Log extends OperationLog
{
    /**
     * 调试日志
     * @param $title
     * @param string $content
     */
    public function debug($title, $content = '无内容')
    {
        $this->insert([
            'level' => 'debug',
            'title' => $title,
            'content' => $content,
            'ip' => app('request')->ip(),
            'updated_at' => Carbon::now(),
            'created_at' => Carbon::now()
        ]);
    }

    /**
     * 消息日志
     * @param $title
     * @param string $content
     */
    public function info($title, $content = '无内容')
    {
        $this->insert([
            'level' => 'info',
            'title' => $title,
            'content' => $content,
            'ip' => app('request')->ip(),
            'updated_at' => Carbon::now(),
            'created_at' => Carbon::now()
        ]);
    }

    /**
     * 错误日志
     * @param $title
     * @param string $content
     */
    public function error($title, $content = '无内容')
    {
        $this->insert([
            'level' => 'error',
            'title' => $title,
            'content' => $content,
            'ip' => app('request')->ip(),
            'updated_at' => Carbon::now(),
            'created_at' => Carbon::now()
        ]);
    }

    /**
     * 警告日志
     * @param $title
     * @param string $content
     */
    public function warn($title, $content = '无内容')
    {
        $this->insert([
            'level' => 'warn',
            'title' => $title,
            'content' => $content,
            'ip' => app('request')->ip(),
            'updated_at' => Carbon::now(),
            'created_at' => Carbon::now()
        ]);
    }
}